@using Elsa.Studio.Workflows.Components.WorkflowDefinitionEditor.Components.WorkflowProperties
@using Orientation = Radzen.Orientation

<CascadingValue Value="this">
    <RadzenSplitter Orientation="Orientation.Horizontal">
        <RadzenSplitterPane Size="65%">

            @if (WorkflowDefinition != null!)
            {
                <MudDynamicTabs @ref="@_dynamicTabs"
                                Style="height: 100%"
                                AddTab="@AddTabCallback"
                                CloseTab="@CloseTabCallback"
                                ActivePanelIndex="0"
                                AddIconToolTip="Click to open a new workflow tab" CloseIconToolTip="Close workflow"
                                Elevation="0"
                                ApplyEffectsToContainer>

                    <MudTabPanel Text="@WorkflowDefinition.Name" ShowCloseIcon="false" Style="height: 100%">
                        @if (!IsReadOnly)
                        {
                            <WorkflowEditor @key="WorkflowDefinition.DefinitionId" @ref="WorkflowEditor" WorkflowDefinition="WorkflowDefinition" WorkflowDefinitionUpdated="OnWorkflowDefinitionUpdated"/>
                        }
                        else
                        {
                            <WorkflowDefinitionVersionViewer WorkflowDefinition="SelectedWorkflowDefinitionVersion"/>
                        }

                    </MudTabPanel>

                </MudDynamicTabs>
            }

        </RadzenSplitterPane>
        <RadzenSplitterPane Size="35%" Min="100px">
            @{
                var workflowDefinition = SelectedWorkflowDefinitionVersion ?? WorkflowDefinition;
            }
            @if (workflowDefinition != null!)
            {
                <WorkflowProperties WorkflowDefinition="@workflowDefinition" OnWorkflowDefinitionUpdated="OnWorkflowDefinitionPropsUpdated"/>
            }
        </RadzenSplitterPane>

    </RadzenSplitter>
</CascadingValue>